package com.cn.pack.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping(path = "/file")
public class UploadFileController {

    @RequestMapping(path = "/upload", method = RequestMethod.POST,
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public String upload(@RequestPart(name = "file") MultipartFile file) {
        System.out.println("fileOriginalName = " + file.getOriginalFilename());
        System.out.println("fileName = " + file.getName());
        System.out.println("size = " + file.getSize());
        return "文件已经成功上传服务器";
    }
}
